package cst.a802yp.myrecycleview_802yp.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import cst.a802yp.myrecycleview_802yp.R;
import cst.a802yp.myrecycleview_802yp.bean.UserInfo;
import cst.a802yp.myrecycleview_802yp.iface.RegisterListener;
import cst.a802yp.myrecycleview_802yp.model.RegisterModel;

public class RegisterActivity extends AppCompatActivity implements RegisterListener, View.OnClickListener {
    private EditText et_username, et_password, et_rePassword, et_tel;
    private Button btn_register, btn_return;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        init();
    }

    private void init() {
        et_username = (EditText) findViewById(R.id.et_username);
        et_password = (EditText) findViewById(R.id.et_password);
        et_rePassword = (EditText) findViewById(R.id.et_rePassword);
        et_tel = (EditText) findViewById(R.id.et_tel);
        btn_register = (Button) findViewById(R.id.btn_register);
        btn_return = (Button) findViewById(R.id.btn_return);
        btn_register.setOnClickListener(this);
        btn_return.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_register:
                String s_username = et_username.getText().toString();
                String password = et_password.getText().toString();
                String tel = et_tel.getText().toString();
                RegisterModel mode = new RegisterModel();
                mode.register(s_username, password, tel, this);
                break;
            case R.id.btn_return:
                break;
        }

    }

    @Override
    public void onResponse(UserInfo regInfo) {

    }

    @Override
    public void onFail(String msg) {

    }
}
